const Subscription = require('egg').Subscription

class GetTime extends Subscription {
    static get schedule() {
        return {
            interval: '2s',
            // the `cron` field is more powerful than `interval`field
            /* 
                            *    *    *    *    *    *
                ┬    ┬    ┬    ┬    ┬    ┬
                │    │    │    │    │    |
                │    │    │    │    │    └ day of week (0 - 7) (0 or 7 is Sun)
                │    │    │    │    └───── month (1 - 12)
                │    │    │    └────────── day of month (1 - 31)
                │    │    └─────────────── hour (0 - 23)
                │    └──────────────────── minute (0 - 59)
                └───────────────────────── second (0 - 59, optional)
             */

            /* `cron` example: each 3 second  to run the schedule task(subscirbe()) */
            // cron: '*/3 * * * * *',
            type: 'worker'
        };
    }
    /* to show the config result,please restart your egg project server to active the tasks 
    write your task content in the `async` subscribe() function.*/
    async subscribe() {

        /* I comment the the task to clean the console. */
        // console.log(`try schedule task (print time:):` + Date())
    }

};

module.exports = GetTime;